/**
 * Created by Administrator on 2017/6/5.
 */
'use strict';


var app = angular.module('app', [
    'ngAnimate',
    'ngAria',
    'ngCookies',
    'ngMessages',
    'ngResource',
    'ngSanitize',
    'ngTouch',
    'ngStorage',
    'ui.router',
    'ui.bootstrap',
    'ui.utils',
    'ui.load',
    'ui.jq',
    'starter.services',
    'data.services',
    'oc.lazyLoad',
    'pascalprecht.translate',
    'ngTable',
    'ngFileUpload',
    'ncy-angular-breadcrumb',
    'cp.ngConfirm'
]);
app.config(['$httpProvider', config]);
function config($httpProvider) {
    $httpProvider.defaults.withCredentials = true;
}

app.run(
    [          '$rootScope', '$state', '$stateParams','storageService',
        function ($rootScope,   $state,   $stateParams,storageService) {
            $rootScope.$state = $state;
            $rootScope.$stateParams = $stateParams;
            $rootScope.AdminInfo =storageService.getObject('AdminInfo');
            $rootScope.$on('$stateChangeSuccess', function(event, to, toParams, from, fromParams) {
                $rootScope.previousState = from;
                $rootScope.previousStateParams = fromParams;

                if(to.name=="home"){
                    $rootScope.showBreadcrumb=false;
                }else{
                    $rootScope.showBreadcrumb=true;
                }
            });
        }
    ]
);
app.config(
    [          '$stateProvider', '$urlRouterProvider',
        function ($stateProvider,   $urlRouterProvider) {
        $stateProvider

            .state('login', {
                url: '/login',
                templateUrl: 'templates/login.html'+'?datestamp=v1.0.0',
                controller:'loginCtrl'
            })
            .state('home', {
                url: '/home',
                abstract: true,
                templateUrl: 'templates/home.html'+'?datestamp=v1.0.0',
                controller:'homeCtrl'
            })
            .state('home.table', {
                url: '/table',
                cache:false,
                templateUrl: 'templates/table.html'+'?datestamp=v1.0.2',
                controller:'tableCtrl',
                // prefetchTemplate:false,
                ncyBreadcrumb: {
                    parent:'home',
                    label: '预约列表'
                }
            })
            .state('home.update', {
                url: '/update',
                cache:false,
                templateUrl: 'templates/updatePassword.html'+'?datestamp=v1.0.2',
                controller:'updateCtrl',
                // prefetchTemplate:false,
                ncyBreadcrumb: {
                    parent:'home',
                    label: '修改密码'
                }
            })
            .state('home.bankList', {
                url: '/bankList',
                cache:false,
                templateUrl: 'templates/bankList.html'+'?datestamp=v1.0.0',
                controller:'bankListCtrl',
                // prefetchTemplate:false,
                ncyBreadcrumb: {
                    parent:'home',
                    label: '银行网点列表'
                }
            })
            .state('home.bankList_update',{
                url:'/bankList_update',
                cache:false,
                templateUrl: 'templates/bank_update.html'+'?datestamp=v1.0.0',
                controller: 'bankUpdateCtrl',
                // prefetchTemplate:false,
                ncyBreadcrumb: {
                    parent:'home',
                    label: '修改银行网点'
                }
            })
            .state('home.bankList_add',{
                url:'/bankList_add',
                cache:false,
                templateUrl: 'templates/bank_add.html'+'?datestamp=v1.0.0',
                // prefetchTemplate:false,
                controller: 'bankAddCtrl',
                ncyBreadcrumb: {
                    parent:'home',
                    label: '添加银行网点'
                }
            })
            .state('home.bankUser_list',{
                url:'/bankUser_list',
                cache:false,
                templateUrl: 'templates/bankUser_list.html'+'?datestamp=v1.0.0',
                // prefetchTemplate:false,
                controller: 'bankUserListCtrl',
                ncyBreadcrumb: {
                    parent:'home',
                    label: '添加银行人员'
                }
            })
            .state('home.bankUser_add', {
                url: '/bankUser_add',
                cache:false,
                templateUrl: 'templates/bankUser_add.html'+'?datestamp=v1.0.3',
                controller:'bankUserAddCtrl',
                // prefetchTemplate:false,
                ncyBreadcrumb: {
                    parent:'home',
                    label: '添加人员账号'
                }
            })
            .state('home.coinList', {
                url: '/coinList',
                cache:false,
                templateUrl: 'templates/coinList.html'+'?datestamp=v1.0.0',
                controller:'coinListCtrl',
                // prefetchTemplate:false,
                ncyBreadcrumb: {
                    parent:'home',
                    label: '银行网点列表'
                }
            })
            .state('home.coin_update',{
                url:'/coin_update',
                cache:false,
                templateUrl: 'templates/coin_update.html'+'?datestamp=v1.0.0',
                controller: 'coinUpdateCtrl',
                // prefetchTemplate:false,
                ncyBreadcrumb: {
                    parent:'home',
                    label: '修改银行网点'
                }
            })
            .state('home.coin_add',{
                url:'/coin_add',
                cache:false,
                templateUrl: 'templates/coin_add.html'+'?datestamp=v1.0.0',
                // prefetchTemplate:false,
                controller: 'coinAddCtrl',
                ncyBreadcrumb: {
                    parent:'home',
                    label: '添加银行网点'
                }
            })
            .state('home.suggestion', {
                url: '/suggestion',
                cache:false,
                templateUrl: 'templates/suggestion.html'+'?datestamp=v1.0.0',
                controller:'suggestionCtrl',
                // prefetchTemplate:false,
                ncyBreadcrumb: {
                    parent:'home',
                    label: '建议投诉列表'
                }
            })
            .state('home.xmeList', {
                url: '/xmeList',
                cache:false,
                templateUrl: 'templates/xmeList.html'+'?datestamp=v1.0.0',
                controller:'xmeListCtrl',
                prefetchTemplate:false,
                ncyBreadcrumb: {
                    parent:'home',
                    label: '银行网点列表'
                }
            })
            .state('home.xmeList_update',{
                url:'/xmeList_update',
                cache:false,
                templateUrl: 'templates/xme_update.html'+'?datestamp=v1.0.0',
                controller: 'xmeUpdateCtrl',
                prefetchTemplate:false,
                ncyBreadcrumb: {
                    parent:'home',
                    label: '修改银行网点'
                }
            })
            .state('home.xmeList_add',{
                url:'/xmeList_add',
                cache:false,
                templateUrl: 'templates/xme_add.html'+'?datestamp=v1.0.0',
                prefetchTemplate:false,
                controller: 'xmeAddCtrl',
                ncyBreadcrumb: {
                    parent:'home',
                    label: '添加银行网点'
                }
            })
            .state('home.blackList', {
                url: '/blackList',
                cache:false,
                templateUrl: 'templates/blacklist.html'+'?datestamp=v1.0.0',
                controller:'blackListCtrl',
                prefetchTemplate:false,
                ncyBreadcrumb: {
                    parent:'home',
                    label: '银行网点列表'
                }
            });

        $urlRouterProvider.otherwise('/login');
        }]);